Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP implement clone method #37

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

rambobinator
Copy link
Collaborator

No description provided.

return self.create(payload, **kwargs)
except KeyError:
raise NotImplementedError("Clone method isn't yet available for {} service."
.format(self.service_name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message isn't correlated to the actual error.

@@ -4,6 +4,7 @@
from thingy import Thingy

from appnexus.client import AppNexusClient, client, services_list
from appnexus.clone_mixin import CloneMixin, clone_services_unrequired_fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for a module just for this mixin. :)

@@ -172,6 +173,8 @@ def create_models(services_list):
if service_name in ("AdQualityRule", "Advertiser", "Campaign",
"Creative", "LineItem", "PaymentRule"):
ancestors.append(ProfileMixin)
if service_name in clone_services_unrequired_fields.keys():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if service_name in clone_services_unrequired_fields.keys():
if service_name in ("Advertiser"):

@@ -172,6 +173,8 @@ def create_models(services_list):
if service_name in ("AdQualityRule", "Advertiser", "Campaign",
"Creative", "LineItem", "PaymentRule"):
ancestors.append(ProfileMixin)
if service_name in clone_services_unrequired_fields.keys():
ancestors.append(CloneMixin)
Copy link
Contributor

@ramnes ramnes Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ancestors.append(CloneMixin)
ancestors.append(CloneMixin)
attrs["_unrequired_fields"] = clone_services_unrequired_fields[service_name]

@@ -172,6 +173,8 @@ def create_models(services_list):
if service_name in ("AdQualityRule", "Advertiser", "Campaign",
"Creative", "LineItem", "PaymentRule"):
ancestors.append(ProfileMixin)
if service_name in clone_services_unrequired_fields.keys():
ancestors.append(CloneMixin)
model = type(service_name, tuple(ancestors), {})
Copy link
Contributor

@ramnes ramnes Jul 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
model = type(service_name, tuple(ancestors), {})
model = type(service_name, tuple(ancestors), attrs)

try:
payload = {}
for field in self.__dict__.keys():
if field not in clone_services_unrequired_fields[type(self).__name__]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if field not in clone_services_unrequired_fields[type(self).__name__]:
if field not in self._unrequired_fields:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants